package com.kl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kl.entity.Coupon;
import com.kl.entity.UserCoupon;
import com.kl.mapper.UserCouponMapper;
import com.kl.service.IUserCouponService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2021-10-29
 */
@Service
public class UserCouponServiceImpl extends ServiceImpl<UserCouponMapper, UserCoupon> implements IUserCouponService {

    @Autowired
    private UserCouponMapper userCouponMapper;

    @Override
    public List<Integer> selectByUserId(String userId) {
        return userCouponMapper.selectByUserId(userId);
    }

    @Override
    public void deleteByCid(Long cid) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("coupon_id",cid);
        userCouponMapper.delete(wrapper);
    }
}
